package com.lizhi.menu.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lizhi.menu.Dto.CommodityCommentDto;
import com.lizhi.menu.domain.CommodityComment;
import com.lizhi.menu.mapper.CommodityCommentMapper;
import com.lizhi.menu.service.ICommodityCommentService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品评论Service业务层处理
 *
 * @author lizhi
 * @date 2023-05-18
 */
@Service
@RequiredArgsConstructor
public class CommodityCommentServiceImpl implements ICommodityCommentService {
    private final CommodityCommentMapper commodityCommentMapper;

    /**
     * 查询商品评论
     *
     * @param id 商品评论主键
     * @return 商品评论
     */
    @Override
    public CommodityComment selectCommodityCommentById(String id) {
        return commodityCommentMapper.selectById(id);
    }

    /**
     * 查询商品评论列表
     *
     * @param commodityComment 商品评论
     * @return 商品评论
     */
    @Override
    public Page<CommodityComment> selectCommodityCommentList(CommodityCommentDto commodityComment) {
        return commodityCommentMapper.selectCommodityCommentList(commodityComment.createPage(),commodityComment);
    }

    /**
     * 新增商品评论
     *
     * @param commodityComment 商品评论
     * @return 结果
     */
    @Override
    public int insertCommodityComment(CommodityComment commodityComment) {
        return commodityCommentMapper.insertCommodityComment(commodityComment);
    }

    /**
     * 修改商品评论
     *
     * @param commodityComment 商品评论
     * @return 结果
     */
    @Override
    public int updateCommodityComment(CommodityComment commodityComment) {
        return commodityCommentMapper.updateCommodityComment(commodityComment);
    }

    /**
     * 批量删除商品评论
     *
     * @param ids 需要删除的商品评论主键
     * @return 结果
     */
    @Override
    public int remove(List<String> ids) {
        return commodityCommentMapper.deleteCommodityCommentByIds(ids);
    }

    /**
     * 删除商品评论信息
     *
     * @param id 商品评论主键
     * @return 结果
     */
    @Override
    public int remove(String id) {
        return commodityCommentMapper.deleteCommodityCommentById(id);
    }
}
